const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const webpack = require('webpack')
const path = require('path')
const AddAssetHtmlWebpackPlugin = require('add-asset-html-webpack-plugin')

const publicPath = '/dist/'

module.exports = {
  mode: 'production',
  devtool: false,
  output: {
    // 自动取入口处的名字
    filename: 'js/[name].[contenthash].js',
    // 公共基础路径
    publicPath: publicPath
  }, 
  optimization: {
    minimizer: [
      // production
      new CssMinimizerPlugin(),
      new TerserPlugin()
    ]
  },
  plugins: [
    // 引入dll文件
    new webpack.DllReferencePlugin({
      manifest: path.resolve(__dirname, '../dll/manifest.json')
    }),
    // 将dll文件引入html
    new AddAssetHtmlWebpackPlugin({
      filepath: path.resolve(__dirname, '../dll/jquery.js')
    })
  ]
}